package com.dinpay.plugin.activity;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.DisplayMetrics;
import android.widget.Toast;
import com.dinpay.plugin.c.a.b;
import com.dinpay.plugin.d.a;
import com.dinpay.plugin.widget.b;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;

public class DinpayBaseActivity extends Activity
{
  private b a;
  private Toast b = null;

  static
  {
    System.loadLibrary("DinpayEntryKey");
  }

  public static boolean e(String paramString)
  {
    return (paramString == null) || (paramString.trim().length() <= 0) || ("null".equalsIgnoreCase(paramString));
  }

  protected static String f(String paramString)
  {
    return paramString.replaceAll(" ", "");
  }

  protected final String a(String paramString)
  {
    try
    {
      byte[] arrayOfByte = paramString.getBytes();
      X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(a.a(getRSAKey()));
      PublicKey localPublicKey = KeyFactory.getInstance("RSA").generatePublic(localX509EncodedKeySpec);
      Cipher localCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
      localCipher.init(1, localPublicKey);
      String str = a.a(com.dinpay.plugin.d.g.a(arrayOfByte, localCipher, 117));
      return str;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return "";
  }

  protected final void a(String paramString1, String paramString2)
  {
    if (DinpayChannelActivity.a != null)
      try
      {
        Intent localIntent = new Intent();
        localIntent.putExtra("xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><dinpay><response><trade_status>" + paramString1 + "</trade_status>" + "</response></dinpay>");
        localIntent.setComponent(new ComponentName(getPackageName(), paramString2));
        startActivity(localIntent);
        ExitApplication.a().b();
        finish();
        return;
      }
      catch (Exception localException)
      {
      }
    finish();
  }

  protected final boolean a()
  {
    NetworkInfo localNetworkInfo = ((ConnectivityManager)getSystemService("connectivity")).getActiveNetworkInfo();
    return (localNetworkInfo != null) && (localNetworkInfo.isConnected());
  }

  protected final String b(String paramString)
  {
    try
    {
      byte[] arrayOfByte = a.a(paramString);
      X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(a.a(getRSAKey()));
      PublicKey localPublicKey = KeyFactory.getInstance("RSA").generatePublic(localX509EncodedKeySpec);
      Cipher localCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
      localCipher.init(2, localPublicKey);
      String str = new String(com.dinpay.plugin.d.g.a(arrayOfByte, localCipher, 128));
      return str;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return "";
  }

  protected final void b()
  {
    finish();
  }

  protected final boolean b(String paramString1, String paramString2)
  {
    try
    {
      byte[] arrayOfByte = paramString1.getBytes();
      X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(a.a(getRSAKey()));
      PublicKey localPublicKey = KeyFactory.getInstance("RSA").generatePublic(localX509EncodedKeySpec);
      Signature localSignature = Signature.getInstance("SHA1WithRSA");
      localSignature.initVerify(localPublicKey);
      localSignature.update(arrayOfByte);
      boolean bool = localSignature.verify(a.a(paramString2));
      return bool;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return false;
  }

  protected final void c(String paramString)
  {
    this.a = new b(this, (int)(0.5F + 280.0F * getResources().getDisplayMetrics().density));
    this.a.show();
    this.a.a(a.b.e);
    this.a.b(paramString);
    this.a.a("确定", new f(this));
    this.a.setOnCancelListener(new g(this));
  }

  protected final void d(String paramString)
  {
    this.a = new b(this, (int)(0.5F + 280.0F * getResources().getDisplayMetrics().density));
    this.a.show();
    this.a.a(a.b.e);
    this.a.b(paramString);
    this.a.a("确定", new h(this));
    this.a.setOnCancelListener(new i(this));
  }

  protected final void g(String paramString)
  {
    if (this.b == null)
      this.b = Toast.makeText(this, paramString, 1);
    while (true)
    {
      this.b.show();
      return;
      this.b.setText(paramString);
      this.b.setDuration(1);
    }
  }

  public native String getRSAKey();
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.dinpay.plugin.activity.DinpayBaseActivity
 * JD-Core Version:    0.6.2
 */